package com.loveprogrammer.eternity.skill.support.skills.passive;

import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.common.Tuple;
import com.loveprogrammer.eternity.skill.support.skills.AbstractPassiveAuraSkill;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0.0
 * @description: 暗影光环
 * @author: eric
 * @date: 2022-08-22 18:07
 **/
public class ShadowAuraSkill extends AbstractPassiveAuraSkill {

    private int decrement;

    public ShadowAuraSkill(int id, int baseInterval, int level, int order, int maxLevel, String name, String desc) {
        super(id, baseInterval, level, order, maxLevel, name, desc);
    }

    @Override
    protected Tuple<String, List<Character>> skillLaunch(Character character,
                                                         List<? extends Character> attack,
                                                         List<? extends Character> defences) {
        Tuple<String, List<Character>> result = new Tuple<>();
        // 减少对方的生命力 护甲 速度
        decrement = getHarm(character);
        StringBuilder builder = new StringBuilder();
        builder.append(character.getName()).append("释放了技能【").append(getName()).append(" (").append(getLevel()).append("级)】\n");
        for (Character member : defences) {
            int max = Math.min((int) (member.getHpMax() * 0.25),decrement * 2 * 10);
            member.getHp().addAndGet(-max);
            member.setHpMax(member.getHp().get());
            member.setArmature(member.getArmature() - decrement/2);
            member.setSpeed(member.getSpeed() - decrement/2);
            builder.append(member.getName()).append("生命值减少")
                    .append(max).append("点，护甲减少").append(decrement / 2).append("点,速度减少")
                    .append(decrement / 2).append("点\n");
        }
        result.setKey(builder.toString());
        result.setValue(new ArrayList<>());
        return result;
    }

    @Override
    protected int computeHarm(Character character) {
        return (int) (character.getTechnique() * 0.1 * ((getBaseHarm() + getLevel()*1.2)/ 100));
    }

    @Override
    protected int computeSecondHarm(Character character) {
        return 0;
    }

    @Override
    public boolean checkLevelUp(int characterLevel) {
        // 每4级升一级
        if(characterLevel % 4 == 0){
            return true;
        }
        return false;
    }

    @Override
    public int defaultHarm() {
        return 100;
    }

    @Override
    public void release(Character character,List<? extends Character> attack, List<? extends Character> defences) {
        for (Character member : defences) {
            member.setArmature(member.getArmature() + decrement/2);
            member.setSpeed(member.getSpeed() + + decrement/2);
        }
    }

}
